package com.xgimi.open.skill.datamanager.domain.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xgimi.open.skill.datamanager.domain.entity.ProductDo;
import com.xgimi.open.skill.datamanager.domain.entity.ProductVersionDo;
import com.xgimi.open.skill.datamanager.domain.service.ProductVersionService;
import com.xgimi.open.skill.datamanager.domain.mapper.ProductVersionMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Objects;

/**
 * @author coderzpw.zhang
 * @description 针对表【product_version(产品版本表)】的数据库操作Service实现
 * @createDate 2023-02-05 17:26:38
 */
@Service
public class ProductVersionServiceImpl extends ServiceImpl<ProductVersionMapper, ProductVersionDo>
        implements ProductVersionService{

    @Override
    public List<ProductVersionDo> queryByPidAndPvName(ProductVersionDo productVersionDo) {
        LambdaQueryWrapper<ProductVersionDo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(!Objects.isNull(productVersionDo.getProductId()), ProductVersionDo::getProductId, productVersionDo.getProductId());
        queryWrapper.eq(!StringUtils.isEmpty(productVersionDo.getVersionName()), ProductVersionDo::getVersionName, productVersionDo.getVersionName());
        return this.list(queryWrapper);
    }

    @Override
    public Boolean saveProductVersion(ProductVersionDo productVersionDo) {
        return this.save(productVersionDo);
    }

    @Override
    public List<ProductVersionDo> queryByPid(Long productId) {
        LambdaQueryWrapper<ProductVersionDo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(!Objects.isNull(productId), ProductVersionDo::getProductId, productId);
        return this.list(queryWrapper);
    }
}




